package player;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
public class Player {

    private static int count=0;
    private static final int MAX = 11;

    public Player(){
        count++;
    }
    public static Player cratePlayer(){
        if (count>=MAX){
            return null;

        }
        return new Player();
    }

    public static int getCount() {
        return count;
    }

    public static void main(String[] args) {
        while (true){
            Player player = Player.cratePlayer();
            if (player==null){
                System.out.println("已创建"+MAX+"个球员");
                break;
            }
            else {
                System.out.println("创建第"+count+"个球员对象");
            }
        }
    }
}
